use serde_derive::{Serialize, Deserialize};
use lucky::{models::{UserCardRow as ModelRow}, json::JsonPager};
use sqlx::{postgres::{PgRow}, row::Row};
use crate::common::{Pool, models::BackendModel};

#[derive(Serialize, Deserialize, Debug)]
pub struct UserCard;

impl BackendModel<ModelRow> for UserCard {

    const TABLE_NAME: &'static str = "user_cards";
    const FIELDS: &'static str = "id, user_id, user_name, province_code, city_code, district_code, bank_id, card_number, real_name, status, sort";

    fn get_row_filter(r: &PgRow) -> ModelRow {
        unfold_fields!(r, {
            id => i32,
            user_id => i32,
            user_name => String,
            province_code => String,
            city_code => String,
            district_code => String,
            bank_id => i32,
            card_number => String,
            real_name => String,
            status => i16,
            sort => i32,
        })
    }
}

impl UserCard {
    record_list!();
}
